<style type="text/css">
    .layui-table-body{overflow-x:auto;}
    .layui-table-cell{font-size:12px;}
</style>
<div class="layui-form hisi-search">
    <form action="{:url()}" method="get" id="hisi-table-search">
        <div class="layui-form-item">
            <label class="layui-form-label">产品名称</label>
            <div class="layui-input-inline">
                <select name="product_id" class="layui-input field-product_id" lay-verify="required" lay-search="">
                  <option value="">直接选择或搜索选择</option>
                  {volist name="products" id='vo'}
                  <option value="{$vo.id}">{$vo.name}</option>
                  {/volist}
                </select>
            </div>
        </div>
        <div class="layui-form-item hisi-search-btn">
            <div class="layui-input-inline">
                <button type="submit" class="layui-btn layui-btn-normal layui-icon layui-icon-search">执行</button>
            </div>
        </div>
    </form>
</div>

<table id="dataTable"></table>

<script type="text/html" id="statusTpl">
    <input type="checkbox" name="status" value="{{ d.status }}" lay-skin="switch" lay-filter="switchStatus" lay-text="正常|关闭" {{ d.status == 1 ? 'checked' : '' }} data-href="{:url('status')}?id={{ d.id }}">
</script>
<script type="text/html" title="操作按钮模板" id="buttonTpl">
    <a href="{:url('edit')}?id={{ d.id }}" class="layui-btn layui-btn-xs layui-btn-normal hisi-iframe-pop"  hisi-data="{width: '550px', height: '420px', title: '修改品牌'}">修改</a><a href="{:url('del')}?id={{ d.id }}" class="layui-btn layui-btn-xs layui-btn-danger j-tr-del">删除</a>
</script>
{include file="system@block/layui" /}
<script id="toolbar" type="text/html">
    <a href="{:url('add')}" class="layui-btn layui-btn-normal layui-btn-sm hisi-iframe-pop" hisi-data="{width: '550px', height: '420px', title: '添加'}">&nbsp;添加</a>
</script>
<script type="text/javascript">
    layui.use(['table'], function() {
        var table = layui.table;
        table.render({
            elem: '#dataTable'
            ,url: '{:url()}' //数据接口
            ,page: true //开启分页
            ,skin: 'row'
            ,even: true
            ,limit: 20
            ,text: {
                none : '暂无相关数据'
            }
            // ,toolbar: '#toolbar'
            ,defaultToolbar: ['filter']
            ,cols: [[ //表头
                {type:'checkbox'}
                ,{field: 'id',width:70, title: 'ID'}
                ,{field: 'name', title: '产品名称'}
                ,{field: 'specs', title: '产品规格'}
                ,{field: 'unit', title: '产品单位',templet:function(d){
                    return d.unit_text + ' / ' + d.decomposition_text
                }}
                ,{field: 'warehousing', title: '产品入库数量'}
                ,{field: 'zong', title: '总库出库数量'}
                ,{field: 'pei', title: '配料库出库数量',templet:function(d){
                    return d.pei + ' / ' + d.specs + ' = ' + d.pei / d.specs;
                }}
                ,{field: 'product_num', title: '产品剩余数量',templet:function(d){
                    return d.warehousing - d.zong - d.pei / d.specs;
                }}
                // ,{field: 'warehouse_text', title: '仓库'}
                // ,{field: 'createtime', title: '创建时间'}
            ]]

        });
    });
</script>
